﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Reflection;
using System.IO;
using System.Xml;

namespace Project1
{
    class MyMain
    {
        enum Color { Yellow = 1, Blue, Green };
        static DateTime thisDate = DateTime.Now;

        static void Main()
        {
            //Console.WriteLine(BitConverter.IsLittleEndian);
            //Console.ReadKey(true);
            //ModelLocator.getInstance().addEventListener(1, Show1);
            //ModelLocator.getInstance().addEventListener(2, Show2);
            //ArrayList arr1 = new ArrayList();
            //arr1.Add(123);
            //ArrayList arr2 = new ArrayList();
            //arr2.Add(456);
            //ModelLocator.getInstance().dispacthEvent(1,arr1);
            //ModelLocator.getInstance().dispacthEvent(2, arr2);
            //ModelLocator.getInstance().removeEventListener(1);
            //ModelLocator.getInstance().dispacthEvent(1, 789);

            //ModelLocator.getInstance().removeEventListener(1);
            //ModelLocator.getInstance().dispacthEvent(1);
            //ModelLocator.getInstance().dispacthEvent(2);


            //INIClass val = new INIClass("D:/C#/MyTest/Project1/Project1/assets/text.txt");
            //val.IniWriteValue("PropertyName", "name1", "gf");
            //val.IniWriteValue("PropertyName", "name1", "gufan");
            //val.IniWriteValue("PropertyName", "name2", "ggff");
            //val.IniWriteValue("PropertyValue", "name1", "ffgg");
            //Console.WriteLine(val.IniReadValue("PropertyName", "name1"));
            //Console.WriteLine(val.IniReadValue("PropertyName", "name2"));
            //Console.WriteLine(val.IniReadValue("PropertyValue", "name1"));
            //Console.Read();

            //ArrayList arr = new ArrayList();
            //arr.Add(123);
            //CallBack val = new CallBack(Test, null, arr);
            //val.Call(true);

            //int val = 123;
            //Console.WriteLine(val.ToString());
            //Console.Read();

            //MyMain my = new MyMain();
            //ArrayList arr = new ArrayList();
            //arr.Add(1);
            //arr.Add(2);
            //ArrayList method = new ArrayList();
            //method.Add(my);
            //method.Add("Test");
            //arr.Add(method);
            //BindManage.addfunc(arr);

            //             string delimStr = " ,.:";
            //             char[] delimiter = delimStr.ToCharArray();
            //             Console.WriteLine(delimiter);
            //             string words = "one two,three:four.";
            //             string[] split = null;
            // 
            //             Console.WriteLine("The delimiters are -{0}-", delimStr);
            //             for (int x = 1; x <= 5; x++)
            //             {
            //                 split = words.Split(delimiter, x);
            //                 Console.WriteLine("\ncount = {0,2} ..............", x);
            //                 foreach (string s in split)
            //                 {
            //                     Console.WriteLine("-{0}-", s);
            //                 }
            //             }
            //             Console.ReadKey();

            //string str = "我是";
            //ASCIIEncoding asc = new ASCIIEncoding();
            //byte[] byteArr = asc.GetBytes(str);
            //for (int i = 0; i < byteArr.Length;i++ )
            //{
            //    Console.WriteLine(byteArr[i]);//63
            //}
            //Console.ReadKey();

            //byte[] bt = ByteArrayTool.StringToBytes(str);
            //Console.WriteLine(bt.Length);
            //Console.WriteLine(str.Length);
            //Console.ReadKey();

            //char[] strArr = str.ToCharArray();
            //for (int i = 0; i < strArr.Length; i++)
            //{
            //    char cstr = strArr[i];
            //    Console.WriteLine(cstr);
            //}
            //Console.ReadKey();

            //byte[] b = Encoding.BigEndianUnicode.GetBytes(str);
            //string o = "";
            //string p = "";
            //foreach (object x in b)
            //{
            //    o += string.Format("{0:X2}", x);
            //}
            //Console.WriteLine(o);
            //Console.ReadKey();


            //String str1 = "*;|@123***456@|;*";
            //String delim = "*;|@";
            //String str2 = str1.Trim(delim.ToCharArray());

            //Console.WriteLine("Delimiters:      {0}", delim);
            //Console.WriteLine("Original string: {0}", str1);
            //Console.WriteLine("Trimmed string:  {0}", str2);
            //Console.ReadKey();


            //ByteArrayEx val = new ByteArrayEx();
            //val.writeInt(2);
            //Console.WriteLine(ByteArrayTool.byteToInt(val.byteArray));
            //Console.ReadKey();

            //Hashtable hs = new Hashtable();
            //string path = "D:/C#/MyTest/Project1/Project1/assets/string.txt";
            //StreamReader sr = new StreamReader(path,Encoding.UTF8);
            //string mainStr = sr.ReadToEnd();
            //string[] splitStr = mainStr.Split(new string[] {"\r\n"},StringSplitOptions.RemoveEmptyEntries);

            //foreach (string val in splitStr)
            //{
            //    string[] spStr = val.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
            //    hs.Add(spStr[0], spStr[1]);
            //}

            //StringReader.getInstance().LoadString("D:/C#/MyTest/Project1/Project1/assets/string.txt");
            //Console.WriteLine("{0},{1},{2}", StringReader.getInstance().GetProperties("skill_1"), 
            //    StringReader.getInstance().GetProperties("skill_2"), 
            //    StringReader.getInstance().GetProperties("skill_3"),
            //    StringReader.getInstance().GetProperties("changeName1"),
            //    StringReader.getInstance().GetProperties("changeName2")
            //);

            //Console.WriteLine(StringReader.getInstance().getSwfLangStrVar("changeName1", "顾凡"));

            //Console.WriteLine(StringReader.getInstance().getSwfLangStrVarEx("changeName2", "顾凡"));


            //string[] info = { "Name: Felica Walker", "Title: Mz.", "Age: 47", "Location: Paris", "Gender: F" };
            //int found = 0;

            //Console.WriteLine("The initial values in the array are:");
            //foreach (string s in info)
            //    Console.WriteLine(s);

            //Console.WriteLine("{0}We want to retrieve only the key information. That is:", Environment.NewLine);

            //foreach (string s in info)
            //{
            //    found = s.IndexOf(":");
            //    Console.WriteLine(s.Substring(found + 1).Trim());
            //}
            //Console.ReadKey();

            //string str = "{abcd}efg";
            //int indexpre = str.IndexOf("{");
            //int indexback = str.IndexOf("}");
            //Console.WriteLine(str.Substring(indexpre, indexback - indexpre+1));
            //Console.ReadKey();

            //string val = "1";
            //Console.WriteLine(int.Parse(val));
            //Console.ReadKey();



            //// Store the output of the String.Format method in a string.
            //string s = "";

            //// Format a negative integer or floating-point number in various ways.
            //Console.WriteLine("Standard Numeric Format Specifiers");
            //s = String.Format(
            //    "(C) Currency: . . . . . . . . {0:C}\n" +
            //    "(D) Decimal:. . . . . . . . . {0:D}\n" +
            //    "(E) Scientific: . . . . . . . {1:E}\n" +
            //    "(F) Fixed point:. . . . . . . {1:F}\n" +
            //    "(G) General:. . . . . . . . . {0:G}\n" +
            //    "    (default):. . . . . . . . {0} (default = 'G')\n" +
            //    "(N) Number: . . . . . . . . . {0:N}\n" +
            //    "(P) Percent:. . . . . . . . . {1:P}\n" +
            //    "(R) Round-trip: . . . . . . . {1:R}\n" +
            //    "(X) Hexadecimal:. . . . . . . {0:X}\n",
            //    -123, -123.45f);
            //Console.WriteLine(s);

            //// Format the current date in various ways.
            //Console.WriteLine("Standard DateTime Format Specifiers");
            //s = String.Format(
            //    "(d) Short date: . . . . . . . {0:d}\n" +
            //    "(D) Long date:. . . . . . . . {0:D}\n" +
            //    "(t) Short time: . . . . . . . {0:t}\n" +
            //    "(T) Long time:. . . . . . . . {0:T}\n" +
            //    "(f) Full date/short time: . . {0:f}\n" +
            //    "(F) Full date/long time:. . . {0:F}\n" +
            //    "(g) General date/short time:. {0:g}\n" +
            //    "(G) General date/long time: . {0:G}\n" +
            //    "    (default):. . . . . . . . {0} (default = 'G')\n" +
            //    "(M) Month:. . . . . . . . . . {0:M}\n" +
            //    "(R) RFC1123:. . . . . . . . . {0:R}\n" +
            //    "(s) Sortable: . . . . . . . . {0:s}\n" +
            //    "(u) Universal sortable: . . . {0:u} (invariant)\n" +
            //    "(U) Universal sortable: . . . {0:U}\n" +
            //    "(Y) Year: . . . . . . . . . . {0:Y}\n",
            //    thisDate);
            //Console.WriteLine(s);

            //// Format a Color enumeration value in various ways.
            //Console.WriteLine("Standard Enumeration Format Specifiers");
            //s = String.Format(
            //    "(G) General:. . . . . . . . . {0:G}\n" +
            //    "    (default):. . . . . . . . {0} (default = 'G')\n" +
            //    "(F) Flags:. . . . . . . . . . {0:F} (flags or integer)\n" +
            //    "(D) Decimal number: . . . . . {0:D}\n" +
            //    "(X) Hexadecimal:. . . . . . . {0:X}\n",
            //    Color.Green);
            //Console.WriteLine(s);


            //string myName = "Fred";
            //Console.WriteLine(String.Format("Name = {0}, hours = {1:hh}", myName, DateTime.Now));
 

            //Console.ReadKey();

            //showw(1,4,"gag");


            //XmlReader.getInstance().LoadXml("D:/C#/MyTest/Project1/Project1/assets/equip.xml",1);

            //Console.WriteLine(XmlReader.getInstance().GetXmlElementValue(1,"equip_1", "Name"));

            //XmlDocument doc = new XmlDocument();
            //doc.LoadXml("<book genre='novel' ISBN='1-861001-57-5'>" +
            //            "<title>Pride And Prejudice</title>" +
            //            "</book>");

            //XmlElement root = doc.DocumentElement;

            //// Change the value of the first attribute.
            //root.Attributes["genre"].Value = "fiction";

            //Console.WriteLine("Display the modified XML...");
            //Console.WriteLine(doc.InnerXml);

            //XmlDocument doc = new XmlDocument();
            //doc.LoadXml("<!DOCTYPE root ["+
            //  "<!ELEMENT root ANY>"+
            //  "<!ELEMENT Person ANY> "+
            //  "<!ELEMENT Customer EMPTY>"+
            //  "<!ELEMENT Team EMPTY>"+
            //  "<!ATTLIST Person SSN ID #REQUIRED>"+
            //  "<!ATTLIST Customer id IDREF #REQUIRED >"+
            //  "<!ATTLIST Team members IDREFS #REQUIRED>]>"+
            //   "<root>"+
            //  "<Person SSN='A111' Name='Fred'/>"+
            //  "<Person SSN='A111'/>"+
            //  "<Person SSN='A222' Name='Tom'/>"+
            //  "<Customer id='A111'/>"+
            //  "<Customer id='A222334444'/>"+
            //  "<Team members='A222334444 A333445555'/>"+
            //   "</root>");

            ////Get the first element with an attribute of type ID and value of A111.
            ////This displays the node <Person SSN="A111" Name="Fred"/>.
            //XmlElement elem = doc.GetElementById("A111");
            //Console.WriteLine(elem.OuterXml);

            ////Get the first element with an attribute of type ID and value of A222.
            ////This displays the node <Person SSN="A222" Name="Tom"/>.
            //elem = doc.GetElementById("A222");
            //Console.WriteLine(elem.OuterXml); 

            //StaticIni.getInstance().LoadINI("D:/C#/MyTest/Project1/Project1/assets/iniText.ini");

            //Console.WriteLine(StaticIni.getInstance().getIniVar("PropertyName", "name1"));
            //Console.WriteLine(StaticIni.getInstance().getIniVar("PropertyValue", "name1"));
            //Console.WriteLine(StaticIni.getInstance().getIniVar("PropertyName", "name"));

            //MyTest.getInstance().init();

            InitXML.getInstance().AnalyzeXml("skill",ModelLocator.getInstance().scene);



            Console.ReadKey();
        }

        private static void showw(params object[] args)
        {
            Console.WriteLine("{0},{1},{2}", args[0], args[1], args[2]);
            Console.ReadKey();
        }

        public void Test(string val1)
        {
            Console.WriteLine("关键测试{0}", val1);
            Console.ReadKey(true);
        }

        public static void Show1(Object obj, DispatchEventArgs e)
        {
            //String str = "我是个示例";
            ////byte[] byt = System.Text.Encoding.Default.GetBytes(str);
            ////Console.WriteLine(System.Text.Encoding.Default.GetString(byt));
            //byte[] byt = System.Text.Encoding.UTF8.GetBytes(str);
            //Console.WriteLine(Encoding.GetEncoding("UTF-8").GetString(byt));

            //Console.WriteLine(sizeof(Byte));
            //Console.WriteLine(sizeof(SByte));
            //Console.WriteLine(sizeof(int));
            //Console.WriteLine(sizeof(uint));
            //Console.WriteLine(sizeof(Int16));
            //Console.WriteLine(sizeof(UInt16));
            //Console.WriteLine(sizeof(Int32));
            //Console.WriteLine(sizeof(UInt32));
            //Console.WriteLine(sizeof(Int64));
            //Console.WriteLine(sizeof(UInt64));
            //Console.WriteLine(sizeof(Boolean));
            //Console.WriteLine(sizeof(char));
            //Console.WriteLine(sizeof(Single));
            //Console.WriteLine(sizeof(Double));

            Console.WriteLine(e.data);
            Console.WriteLine("调试1");
            Console.ReadKey(true);
            //ModelLocator.getInstance().removeEventListener(1, Show1);
        }

        public static void Show2(Object obj, DispatchEventArgs e)
        {
            Console.WriteLine(e.data);
            Console.WriteLine("调试2");
            Console.ReadKey(true);
        }
    }
}